package com.baiqian.doupo.command;

import com.baiqian.doupo.DouPo;
import com.baiqian.doupo.Utils;
import com.baiqian.doupo.capability.DouPoModCapability;
import com.baiqian.doupo.capability.douqi.IDouQiCapability;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.command.CommandSource;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.common.util.LazyOptional;

public class ShowFire implements Command<CommandSource> {
    public static ShowFire instance = new ShowFire();

    @Override
    public int run(CommandContext<CommandSource> context) {
        LazyOptional<IDouQiCapability> douQiCap = context.getSource().getEntity().getCapability(DouPoModCapability.DOUQI_CAPABILTTY);
        if(douQiCap.isPresent()){
            douQiCap.ifPresent((newCap) -> {
                context.getSource().sendFeedback(new TranslationTextComponent("message." + Utils.MOD_ID + ".fire_show"), false);
                boolean[] fire=newCap.getFire();
                for(int i = 0; i< DouPo.FIRE_MAX; ++i)
                    if(fire[i])
                        context.getSource().sendFeedback(new TranslationTextComponent("item."+ Utils.MOD_ID + ".yi_huo_"+(i+1)), false);
            });
        }
        return 0;
    }
}
